#ifndef TCP_SOCKET_H
#define TCP_SOCKET_H

#include "InetAddress.h"

class Socket{
public:
    explicit Socket(int sockfd): sockfd_(sockfd) {}

    ~Socket();

    /**
     * 获取维护的socket文件描述符
     * @return
     */
    int fd() const { return sockfd_; }

    /**
     * bind操作封装
     * @param addr
     */
    void bindAddress(const InetAddress & addr);

    /**
     * listent操作封装
     */
    void listen();

    /**
     * acception操作封装, 返回对应结果
     */
    int accept(InetAddress * peeraddr);

private:
    const int sockfd_;
};

#endif //TCP_SOCKET_H
